﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


public interface IHander
{
    void Register(Dictionary<Protocal,Action<ByteBuffer>> handlers);
}
/// <summary>
/// 消息的分发和调度
/// </summary>
class HanderCenter
{
    protected Dictionary<Protocal, Action<ByteBuffer>> handlers = new Dictionary<Protocal, Action<ByteBuffer>>();

    AccountHandler accountHandler = new AccountHandler();
    BattleHandler battleHandler = new BattleHandler();

    public HanderCenter()
    {
        accountHandler.Register(handlers);
        battleHandler.Register(handlers);
    }

    public void ReceiveMessage(ByteBuffer buffer)
    {
        Protocal type = (Protocal)buffer.ReadByte();
        handlers[type](buffer);
    }
}